package com.bezdelnick.forum.web;

import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.component.IRequestablePage;
import org.apache.wicket.request.handler.ListenerInterfaceRequestHandler;
import org.apache.wicket.request.mapper.MountedMapper;
import org.apache.wicket.request.mapper.info.PageComponentInfo;
import org.apache.wicket.request.mapper.parameter.PageParametersEncoder;

/**
 * Created by IntelliJ IDEA.
 * User: Bezdelnick
 * Date: 15.08.12
 * Time: 21:53
 * To change this template use File | Settings | File Templates.
 */
public class MountedMapperWithoutPageComponentInfo extends MountedMapper {

  public MountedMapperWithoutPageComponentInfo(String mountPath, Class<? extends IRequestablePage> pageClass) {
    super(mountPath, pageClass, new PageParametersEncoder());
  }

  @Override
  protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
    // do nothing so that component info does not get rendered in url
  }

  @Override
  public Url mapHandler(IRequestHandler requestHandler)
  {
      if (requestHandler instanceof ListenerInterfaceRequestHandler) {
          return null;
      } else {
           return super.mapHandler(requestHandler);
      }
  }
}
